<!--
 * @Description:
 * @Version: 1.0
 * @Author: liguansheng
 * @Date: 2022-08-05 11:00:49
 * @LastEditors: liguansheng
 * @LastEditTime: 2022-09-14 13:58:46
-->
<template>
  <el-scrollbar max-height="100%">
    <el-descriptions
      v-for="(item, index) in actions"
      :key="index"
      :column="2"
      border
      size="small"
    >
      <el-descriptions-item
        :span="2"
        label="ID"
        width="150px"
      >
        {{ item.id }}
      </el-descriptions-item>
      <el-descriptions-item
        label="auditLogId"
        width="150px"
      >
        {{ item.auditLogId }}
      </el-descriptions-item>
      <el-descriptions-item
        label="时间"
        width="150px"
      >
        {{ parseDate2Str(item.executionTime, 'YYYY-MM-DD HH:mm:ss') }}
      </el-descriptions-item>
      <el-descriptions-item
        label="耗时/ms"
      >
        {{ item.executionDuration }}ms
      </el-descriptions-item>
      <el-descriptions-item
        label="方法名称"
      >
        {{ item.methodName }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="2"
        label="服务名称"
      >
        {{ item.serviceName }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="2"
        label="参数"
      >
        <pre>{{
                  JSON.parse(item.parameters)
                }}
              </pre>
      </el-descriptions-item>
    </el-descriptions>
  </el-scrollbar>
</template>

<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import { parseDate2Str } from '@/utils/timeUtils'
import { IActions } from '@/http/types/auditLog'
import { getAuditActionList } from '@/http/auditLog'

const props = defineProps({
  auditLogId: {
    type: String,
    default: ''
  }
})
onMounted(() => {
  init()
})
const actions = ref<IActions[]>([])

const init = async () => {
  const res = await getAuditActionList(props.auditLogId)
  actions.value = res.items
}
</script>

<style lang="scss" scoped>
.el-descriptions{
  margin-bottom: 40px;
}
pre{
  background: rgb(43,43,43);
  color: #ffffff;
  padding: 10px;
}
</style>
